import pymysql


def ihrm_database(sql):
    connect = None
    cursor = None
    try:
        connect = pymysql.connect(host="211.103.136.244",
                                  port=7061,
                                  user="student",
                                  password="iHRM_student_2022",
                                  database="ihrm",
                                  charset='utf8')
        cursor = connect.cursor()
        cursor.execute(sql)
        row = connect.affected_rows()
        print(f'此次操作影响数据库{row}行数据')
        connect.commit()
    except Exception as a:
        print('此次操作有异常，异常为', str(a))
        connect.rollback()
    finally:
        cursor.close()
        connect.close()





# if __name__ == '__main__':
#     ihrm_database("delete from bs_user where mobile='13200000125';")